import request from '@/utils/request';

// 登录方法
export function login(   userName,
                         passWord,
                         code,
                         uuid) {
  const data = {
    userName,
    passWord,
    code,
    uuid,
  };

  return request({
    url: '/auth/login',
    method: 'get',
    params: data,
  });
}

// 刷新TOKEN
export function refreshToken(refreshToken) {
  return request({
    url: '/auth/getauthbyrefresh',
    // url: 'http://localhost:81/auth/getauthbyrefresh',
    method: 'get',
    params: { 'refreshToken': refreshToken },
  });
}

// 获取用户详细信息
export function getInfo() {
  return request({
    url: '/auth/getuserinfo',
    method: 'get',
  });
}

/*export function getuserinfobyauth() {
  return request({
    url: '/auth/getuserinfobyauth',
    method: 'get',
  });
}*/
export function getuserinfobyauth() {
  return request({
    url: '/erp/hrm/user/getuserinfobyauth',
    method: 'get',
  });
}

// 退出方法
export function logout() {
  return request({
    url: '/auth/logout',
    method: 'get',
  });
}

// 获取验证码
export function getCodeImg() {
  return request({
    url: '/captchaImage',
    method: 'get',
  });
}

// 查询功能下拉树结构
export function treeselect(parentId = 0) {
  return request({
    url: '/auth/gettreelist',
    method: 'get',
    params: { parentId: parentId },
  });
}

/*=============begin:钉钉扫码登录*/
//获取用户信息 by code
export function getUserInfoByDingdingCode(code,platmentId) {
  return request({
    url: '/ding/user/getuserbycode',
    method: 'get',
    params: {
      code: code,
      platmentId: platmentId,
    },
  });
}

//注册并且绑定dingding /hrm/user/regbythird
export function registerUserInfoAndBindDINGDING(data) {
  return request({
    url: '/erp/hrm/user/regbythird',
    method: 'post',
    data: data,
  });
}

//绑定钉钉 /auth/loginandbind
export function bindDingding(data) {
  return request({
    url: '/auth/loginandbind',
    method: 'post',
    data: data,
  });
}

//获取钉钉二维码的goto参数
export function dingdingCodeGOTO(platmentId) {
  return request({
    url: '/ding/user/getloginimg',
    method: 'get',
    params: {platmentId},
  });
}

export function dingDingGetuserbyunionid({platmentId,unionid}) {
  return request({
    url: '/ding/user/getuserbyunionid',
    method: 'get',
    params: {platmentId,unionid},
  });
}

// 请求 URL: http://api.szqerp.com/auth/getmenu?menuId=0
export function authgetmenu(menuId=0) {
  return request({
    url: `/auth/getmenu?menuId=${menuId}&funTypes=1,2`,
    method: 'get',
  });
}

/*=============end:钉钉扫码登录*/
